package ControlLayer;
import java.util.ArrayList;

import ModelLayer.*;
import DBLayer.*;

public class CtrGunReplicas {
	DBGunReplicas dbGr;
	GunReplicas gr;
	
	CtrGunReplicas(){
		dbGr = new DBGunReplicas();
		gr = new GunReplicas();
	}
	
	public ArrayList<GunReplicas> getAll(){
		return dbGr.getAll();
		
	}
	
	public GunReplicas searchByName(String name){
		return dbGr.find(name) ;
		
	}
	
	public GunReplicas searchByID(int id){
		return dbGr.find_byID(id);
		
	}
	
	public int delete(int Prid){
		return dbGr.delete(Prid);
	}
	
	public int updateGunReplicas(int Prid, String name, double purchasePrice, double salesPrice, double rentPrice, String countryOfOrigin, int currentStock, int minStock, int sid, String fabric, double caliber){
		GunReplicas gunReplicas = new GunReplicas(Prid, name, purchasePrice, salesPrice, rentPrice, countryOfOrigin, currentStock, minStock, sid, fabric, caliber);
		return dbGr.update(gunReplicas);
	}
	
	public int insert(String name, double purchasePrice, double salesPrice, double rentPrice, String countryOfOrigin, int currentStock, int minStock, int sid, String fabric, double caliber){
		GunReplicas gunReplicas = new GunReplicas(-1, name, purchasePrice, salesPrice, rentPrice, countryOfOrigin, currentStock, minStock, sid, fabric, caliber);
		int rc = -1;
		try{
			
			rc = dbGr.insert(gunReplicas);
			
		}catch(Exception e){
			System.out.println("Error with inserting a product");
		}
		return rc;
	}
	
	
}
